package com.gourd.quartz.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author gourd
 */
@Component
@Slf4j
@ConditionalOnProperty(name = "schedule.gourd.enabled", havingValue = "true")
public class MySpringTask {

    /**
     * spring task
     */
    @Scheduled(cron = "* 0/60 * * * ? ")
    public void doTask(){
        log.info(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()) + "  "+ Thread.currentThread().getName());
    }
}
